package de.test.NeutrinoAndroidRemote.Tools;

import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Parser {
	
	public static Map<String, Integer> GetBouquets(String bouquetString){
		Map<String, Integer> myMap = new HashMap<String, Integer>();
		
		StringTokenizer tk = new StringTokenizer(bouquetString,"\n");
		
		while(tk.hasMoreTokens())
		{
			String item = tk.nextToken();
			String number =  item.substring(0, item.indexOf(' '));
			String name = item.substring(item.indexOf(' ')+1, item.length());
			
			myMap.put(name, Integer.parseInt(number));
		}
		return myMap;
	}
	
	public static Map<String, String> GetChannels(String channelList){
		Map<String, String> myMap = new HashMap<String, String>();
		
		StringTokenizer tk = new StringTokenizer(channelList,"\n");
		while(tk.hasMoreTokens())
		{
			String item = tk.nextToken();
			String number =  item.substring(0, item.indexOf(' '));
			item = item.substring(item.indexOf(' ')+1); //number abschneiden
			String id = item.substring(0, item.indexOf(' '));
			String name = item.substring(item.indexOf(' ')+1); //number abschneiden
			
			myMap.put(name, id);
		}
		return myMap;
	}
	
	

}
